home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2004 April / Gamestar_61_2004-04_dvdb.iso / DVDStar / Editace / hltp.exe / {app} / Source Code / Zoners Half-Life Tools / hlbsp / bsp5.h next >
C/C++ Source or Header  |  2002-11-15  |  9KB  |  268 lines

  1. #ifndef HLBSP_H__
  2. #define HLBSP_H__
  3.  
  4. #if _MSC_VER >= 1000
  5. #pragma once
  6. #endif
  7.  
  8. #include "cmdlib.h"
  9. #include "messages.h"
  10. #include "win32fix.h"
  11. #include "log.h"
  12. #include "hlassert.h"
  13. #include "mathlib.h"
  14. #include "bspfile.h"
  15. #include "blockmem.h"
  16. #include "filelib.h"
  17. #include "threads.h"
  18. #include "winding.h"
  19.  
  20. #define ENTITIES_VOID "entities.void"
  21. #define ENTITIES_VOID_EXT ".void"
  22.  
  23. #define    BOGUS_RANGE    18000
  24.  
  25. // the exact bounding box of the brushes is expanded some for the headnode
  26. // volume.  is this still needed?
  27. #define    SIDESPACE    24
  28.  
  29. //============================================================================
  30.  
  31. #define MIN_SUBDIVIDE_SIZE      64
  32.  
  33. #ifdef ZHLT_GENERAL
  34. #define MAX_SUBDIVIDE_SIZE      512
  35. #else
  36. #define MAX_SUBDIVIDE_SIZE      240
  37. #endif
  38.  
  39. #define DEFAULT_SUBDIVIDE_SIZE  240
  40.  
  41. #define MIN_MAXNODE_SIZE        64
  42. #define MAX_MAXNODE_SIZE        4096
  43. #define DEFAULT_MAXNODE_SIZE    1024
  44.  
  45. #define DEFAULT_NOFILL          false
  46. #define DEFAULT_NOTJUNC         false
  47. #define DEFAULT_NOCLIP          false
  48. #define DEFAULT_LEAKONLY        false
  49. #define DEFAULT_WATERVIS        false
  50. #define DEFAULT_CHART           false
  51. #define DEFAULT_INFO            true
  52.  
  53. #ifdef ZHLT_NULLTEX // AJM
  54. #define DEFAULT_NULLTEX             true
  55. #endif
  56.  
  57. #ifdef ZHLT_PROGRESSFILE // AJM
  58. #define DEFAULT_PROGRESSFILE NULL // progress file is only used if g_progressfile is non-null
  59. #endif
  60.  
  61. #ifdef SYSTEM_WIN32
  62. #define DEFAULT_ESTIMATE        false
  63. #endif
  64.  
  65. #ifdef SYSTEM_POSIX
  66. #define DEFAULT_ESTIMATE        true
  67. #endif
  68.  
  69. #ifdef ZHLT_DETAIL // AJM
  70. #define DEFAULT_DETAIL      true
  71. #endif
  72.  
  73. #define    MAXEDGES            48                 // 32
  74. #define    MAXPOINTS            28                 // don't let a base face get past this
  75.                                                                               // because it can be split more later
  76. #define MAXNODESIZE     1024                               // Valve default is 1024
  77.  
  78. typedef enum
  79. {
  80.     face_normal = 0,
  81.     face_hint,
  82.     face_skip,
  83. #ifdef ZHLT_NULLTEX // AJM
  84.     face_null,
  85. #endif
  86. #ifdef ZHLT_DETAIL // AJM
  87.     face_detail
  88. #endif
  89. }
  90. facestyle_e;
  91.  
  92. typedef struct face_s                                      // This structure is layed out so 'pts' is on a quad-word boundary (and the pointers are as well)
  93. {
  94.     struct face_s*  next;
  95.     int             planenum;
  96.     int             texturenum;
  97.     int             contents;                              // contents in front of face
  98.  
  99.     struct face_s*  original;                              // face on node
  100.     int             outputnumber;                          // only valid for original faces after write surfaces
  101.     int             numpoints;
  102.     facestyle_e     facestyle;
  103.  
  104.     // vector quad word aligned
  105.     vec3_t          pts[MAXEDGES];                         // FIXME: change to use winding_t
  106.  
  107. }
  108. face_t;
  109.  
  110. typedef struct surface_s
  111. {
  112.     struct surface_s* next;
  113.     int             planenum;
  114.     vec3_t          mins, maxs;
  115.     struct node_s*  onnode;                                // true if surface has already been used
  116.     // as a splitting node
  117.     face_t*         faces;                                 // links to all the faces on either side of the surf
  118. }
  119. surface_t;
  120.  
  121. typedef struct
  122. {
  123.     vec3_t          mins, maxs;
  124.     surface_t*      surfaces;
  125. }
  126. surfchain_t;
  127.  
  128. //
  129. // there is a node_t structure for every node and leaf in the bsp tree
  130. //
  131. #define    PLANENUM_LEAF        -1
  132.  
  133. typedef struct node_s
  134. {
  135.     surface_t*      surfaces;
  136.  
  137.     vec3_t          mins, maxs;                            // bounding volume of portals;
  138.  
  139.     // information for decision nodes       
  140.     int             planenum;                              // -1 = leaf node       
  141.     struct node_s*  children[2];                           // only valid for decision nodes
  142.     face_t*         faces;                                 // decision nodes only, list for both sides
  143.  
  144.     // information for leafs
  145.     int             contents;                              // leaf nodes (0 for decision nodes)
  146.     face_t**        markfaces;                             // leaf nodes only, point to node faces
  147.     struct portal_s* portals;
  148.     int             visleafnum;                            // -1 = solid
  149.     int             valid;                                 // for flood filling
  150.     int             occupied;                              // light number in leaf for outside filling
  151. }
  152. node_t;
  153.  
  154. #define    NUM_HULLS        4
  155.  
  156. //=============================================================================
  157. // solidbsp.c
  158. extern void     SubdivideFace(face_t* f, face_t** prevptr);
  159. extern node_t*  SolidBSP(const surfchain_t* const surfhead);
  160.  
  161. //=============================================================================
  162. // merge.c
  163. extern void     MergePlaneFaces(surface_t* plane);
  164. extern void     MergeAll(surface_t* surfhead);
  165.  
  166. //=============================================================================
  167. // surfaces.c
  168. extern void     MakeFaceEdges();
  169. extern int      GetEdge(const vec3_t p1, const vec3_t p2, face_t* f);
  170.  
  171. //=============================================================================
  172. // portals.c
  173. typedef struct portal_s
  174. {
  175.     dplane_t        plane;
  176.     node_t*         onnode;                                // NULL = outside box
  177.     node_t*         nodes[2];                              // [0] = front side of plane
  178.     struct portal_s* next[2];
  179.     Winding*        winding;
  180. }
  181. portal_t;
  182.  
  183. extern node_t   g_outside_node;                            // portals outside the world face this
  184.  
  185. extern void     AddPortalToNodes(portal_t* p, node_t* front, node_t* back);
  186. extern void     RemovePortalFromNode(portal_t* portal, node_t* l);
  187. extern void     MakeHeadnodePortals(node_t* node, const vec3_t mins, const vec3_t maxs);
  188.  
  189. extern void     FreePortals(node_t* node);
  190. extern void     WritePortalfile(node_t* headnode);
  191.  
  192. //=============================================================================
  193. // tjunc.c
  194. void            tjunc(node_t* headnode);
  195.  
  196. //=============================================================================
  197. // writebsp.c
  198. extern void     WriteClipNodes(node_t* headnode);
  199. extern void     WriteDrawNodes(node_t* headnode);
  200.  
  201. extern void     BeginBSPFile();
  202. extern void     FinishBSPFile();
  203.  
  204. //=============================================================================
  205. // outside.c
  206. extern node_t*  FillOutside(node_t* node, bool leakfile, unsigned hullnum);
  207. extern void     LoadAllowableOutsideList(const char* const filename);
  208. extern void     FreeAllowableOutsideList();
  209.  
  210. //=============================================================================
  211. // misc functions
  212. extern void     GetParamsFromEnt(entity_t* mapent);
  213.  
  214. extern face_t*  AllocFace();
  215. extern void     FreeFace(face_t* f);
  216.  
  217. extern struct portal_s* AllocPortal();
  218. extern void     FreePortal(struct portal_s* p);
  219.  
  220. extern surface_t* AllocSurface();
  221. extern void     FreeSurface(surface_t* s);
  222.  
  223. extern node_t*  AllocNode();
  224.  
  225. extern bool     CheckFaceForHint(const face_t* const f);
  226. extern bool     CheckFaceForSkip(const face_t* const f);
  227. #ifdef ZHLT_NULLTEX// AJM
  228. extern bool     CheckFaceForNull(const face_t* const f);
  229. #endif
  230. #ifdef ZHLT_DETAIL // AJM
  231. extern bool     CheckFaceForDetail(const face_t* const f);
  232. #endif
  233.  
  234. //=============================================================================
  235. // cull.c
  236. extern void     CullStuff();
  237.  
  238. //=============================================================================
  239. // qbsp.c
  240. extern bool     g_nofill;
  241. extern bool     g_notjunc;
  242. extern bool     g_watervis;
  243. extern bool     g_chart;
  244. extern bool     g_estimate;
  245. extern int      g_maxnode_size;
  246. extern int      g_subdivide_size;
  247. extern int      g_hullnum;
  248. extern bool     g_bLeakOnly;
  249. extern bool     g_bLeaked;
  250. extern char     g_portfilename[_MAX_PATH];
  251. extern char     g_pointfilename[_MAX_PATH];
  252. extern char     g_linefilename[_MAX_PATH];
  253. extern char     g_bspfilename[_MAX_PATH];
  254.  
  255.  
  256. #ifdef ZHLT_DETAIL // AJM
  257. extern bool g_bDetailBrushes;
  258. #endif
  259.  
  260. #ifdef ZHLT_NULLTEX // AJM
  261. extern bool     g_bUseNullTex; 
  262. #endif
  263.  
  264. extern face_t*  NewFaceFromFace(const face_t* const in);
  265. extern void     SplitFace(face_t* in, const dplane_t* const split, face_t** front, face_t** back);
  266.  
  267. #endif // qbsp.c====================================================================== HLBSP_H__
  268.